package example;

import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;

import object.Course;
import object.Department;
import object.Gender;
import object.PersonInfo;
import object.Score;
import object.ScoreDetail;
import object.ScoreList;
import object.ScoreType;
import object.Student;
import object.StudentList;
import util.ScoreGenerator;

public class StudentListExampleOne {
	
	public static StudentList getStudentListExample(){
		String sid="131250048";
		PersonInfo personInfo=getPersonInfoExample();
		String grade="2013";
		List<Course> courses=getCourseListExample();
		ScoreList scoreList=getScoreListExample();
		Student student=new Student(sid,personInfo,grade);
		student.setCourseList(courses);
		student.setScoreList(scoreList);
		StudentList list=new StudentList();
		list.addStudent(student);
		return list;
	}
	
	public static Department getDepartmentExample(){
		String did="d0001";
		String dname="软件学院";
		Calendar establishment=Calendar.getInstance();
		//establishment.set(2000, 1, 1);
		String dinfo="南京大学软件学院";
		Department department=new Department(did,dname,establishment,dinfo);
		return department;
	}
	
	public static PersonInfo getPersonInfoExample(){
		String firstname="予扬";
		String lastname="华";
		Gender gender=Gender.MALE;
		String mail="15850562037@163.com";
		String tele="15850562037";
		String country="中国";
		String province="江苏";
		String city="南京";
		String info="我是华予扬";
		Department department=getDepartmentExample();
		Calendar birth=Calendar.getInstance();
		//birth.set(1994, 11, 29);
		PersonInfo personInfo=new PersonInfo(firstname,lastname,gender,birth);
		personInfo.setMail(mail);
		personInfo.setTele(tele);
		personInfo.setCountry(country);
		personInfo.setProvince(province);
		personInfo.setCity(city);
		personInfo.setInfo(info);
		personInfo.setDepartment(department);
		return personInfo;
	}
	
	public static List<Course> getCourseListExample(){
		List<Course> courses=new LinkedList<Course>();
		String[] cids={"c0001","c0002","c0003"};
		String[] cnames={"SOA","人机交互","测试"};
		String[] cinfo={"这是SOA","这是人机交互","这是测试"};
		int[] counts={20,20,20};
		for(int i=0;i<cids.length;i++){
			Course course=new Course(cids[i],cnames[i]);
			course.setCinfo(cinfo[i]);
			course.setCount(counts[i]);
			courses.add(course);
		}
		return courses;
	}
	
	public static ScoreList getScoreListExample(){
		String[] cids={"c0001","c0002","c0003"};
		ScoreType[] types={ScoreType.USUAL,ScoreType.HOMEWORK,ScoreType.MID};
		String sid="131250048";
		ScoreDetail[] details=new ScoreDetail[9];
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				details[3*i+j]=new ScoreDetail(sid,ScoreGenerator.generateFailureScore());
			}
		}
		ScoreList list=new ScoreList();
		for(int i=0;i<3;i++){
			List<ScoreDetail> detailList=new LinkedList<ScoreDetail>();
			detailList.add(details[3*i]);
			detailList.add(details[3*i+1]);
			detailList.add(details[3*i+2]);
			Score score=new Score(cids[i],types[i],detailList);
			list.addScore(score);
		}
		return list;
	}

}
